package com.hxzy.controller.admin;

import com.hxzy.common.vo.R;
import com.hxzy.dto.system.SysDeptSearchDTO;
import com.hxzy.entity.system.SysDept;
import com.hxzy.service.system.SysDeptService;
import com.hxzy.vo.SysDeptVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 部门
 * @author Administrator
 */
@Api(tags = "部门API")
@RestController
@RequestMapping(value = "/api/dept")
public class SysDeptController extends BaseController{

    @Autowired
    private SysDeptService sysDeptService;

    @PreAuthorize(value = "@ss.hasAuthority('system:dept:list')")
    @ApiOperation(value = "部门查询")
    @GetMapping(value = "/data")
    public R search(SysDeptSearchDTO searchDTO){
        List<SysDept> arr= this.sysDeptService.search(searchDTO);

        List<SysDeptVO> resultArr=this.sysDeptService.buildDept(arr);
        return R.okHasData(resultArr);
    }

}
